package cn.wolfcode.p2p.controller;

import cn.wolfcode.p2p.business.query.BidRequestQuery;
import cn.wolfcode.p2p.business.service.IBidRequestService;
import cn.wolfcode.p2p.util.CalculatetUtil;
import cn.wolfcode.p2p.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class MainController {
    @Autowired
    private IBidRequestService bidRequestService;

    @RequestMapping("index")
    public String main(Model model) {
        //查询发标公告 ,5条, 升序
        BidRequestQuery qo = new BidRequestQuery();
        qo.setBidRequestState(Constants.BIDREQUEST_STATE_PUBLISH_PENDING);
        qo.setOrderBy("br.publish_time");
        qo.setPageSize(5);
        model.addAttribute("pageInfo", bidRequestService.query(qo));

        //投标中>还款中>已完成  顺序排序
        qo.setOrderBy("br.publish_time");
        qo.setBidRequestStates(new Integer[]{Constants.BIDREQUEST_STATE_BIDDING, Constants.BIDREQUEST_STATE_PAYING_BACK,Constants.BIDREQUEST_STATE_COMPLETE_PAY_BACK});
        model.addAttribute("bidRequests", bidRequestService.query(qo));
        return "main";
    }

}
